// 1
function demo(n:string|number):number {
  let len:number
  // len = n.length
  len = (<string>n).length
  len = (n as string).length
  return len
}

console.log(demo('huatianxiao'))

// 2
let myname01: 'sunxiaoshuang'
myname01 = 'sunxiaoshuang'

let myname02 = 'sunxiaoshuang' as const
myname02 = 'sunxiaoshuang'

// 3
function demo002(a:number,b:number) {
  let num = a + b
  let func = (x:number, z:number):number => x + z
  // return [num, func]
  // return [num, func] as [number, Function]
  // return [num, func] as [typeof num, typeof func]
  return [num, func] as const
}
let [funcA, funcB] = demo002(1, 2)
// let [funcA, funcB] = demo002(1, 2) as [number, (a:number, b:number) => number]
console.log(funcA.toFixed())
console.log(funcB(5, 6))
